﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:output method="html" indent="yes"/>

  <xsl:template match="/SearchActions">
  <!--<xsl:template name="SortActionsTemplate">    -->
    <div class="srch-sort-right">
      Sort by:
      <xsl:for-each select="SortAction">
        <xsl:text xml:space="preserve"> | </xsl:text>

        <xsl:variable name="url" select="SortActionUrl"/>
        <xsl:variable name="selectedSort" select="SelectedSortDirection"/>
        <xsl:variable name="isRankprofile" select="IsRankProfile"/>
        <xsl:variable name="isSelected" select="@isSelected"/>
        <xsl:choose>
          <xsl:when test="$isSelected = 'true'">
            <b>
              <a href="{$url}"><xsl:value-of select="DisplayName"/></a>
            </b>
            <xsl:if test="$isRankprofile = 'False'">
               <xsl:if test="$selectedSort = '+'">
                 <a href="{$url}"><img style="border:0px;" src="/_layouts/images/ewr132.gif" alt="Switch Sort Direction (currently ascending)"></img></a>
               </xsl:if>
               <xsl:if test="$selectedSort = '-'">
                 <a href="{$url}">
                   <img src="/_layouts/images/ewr131.gif" style="border:0px;"  alt="Switch Sort Direction (currently descending)"></img>
                 </a>
               </xsl:if>
            </xsl:if>
          </xsl:when>
          <xsl:otherwise>
            <a href="{$url}">
              <xsl:value-of select="DisplayName"/>
            </a>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each>
    </div>
  </xsl:template>
</xsl:stylesheet>
